package com.rerun.phone.memberuser;

import com.baomidou.mybatisplus.plugins.Page;
import com.rerun.common.anno.ResponseExceptionReturn;
import com.rerun.common.bean.Rest;
import com.rerun.common.controller.SuperController;
import com.rerun.entity.JobFeedback;
import com.rerun.service.IJobFeedbackService;
import com.rerun.service.IMemberPostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * The type Member post controller.
 *
 * @author dax.
 * @version v1.0
 * @since 2017 /10/12 10:21
 */
@Api(value = "求职端-简历投递", description = "求职端-简历投递")
@RestController
@RequestMapping("/memberApi/memberPost")
public class MemberPostController extends SuperController {
    @Resource
    private IMemberPostService iMemberPostService;
    @Resource
    private IJobFeedbackService iJobFeedbackService;

    /**
     * Post resume rest.
     *
     * @param memberId the member id
     * @param jobId    the job id
     * @return the rest
     */
    @ApiOperation(value = "简历投递", notes = "简历投递", httpMethod = "POST")
    @RequestMapping(value = "/resumePost", method = RequestMethod.POST)
    @ResponseExceptionReturn
    public Rest postResume(HttpServletRequest request, String memberId, String jobId) throws IOException, MessagingException {
        return iMemberPostService.postResume(request, memberId, jobId);
    }

    /**
     * Post resume rest.
     *
     * @param status the status
     * @return the rest
     * @see com.rerun.enums.ResumeStateEnum
     */
    @ApiOperation(value = "简历反馈 包括面试信息  根据不同的状态值查询", notes = "根据不同的状态查询简历投递反馈情况 0  查询所有投递简历 100 所有已经投递未处理的  101 被查看过的 200 邀请面试的 300 通过面试 400 拒绝 ", httpMethod = "GET")
    @RequestMapping(value = "/list/status/{memberId}/{pageNumber}", method = RequestMethod.GET)
    @ResponseExceptionReturn
    public Rest selectByStatus(  long status, @PathVariable("memberId") String memberId, @PathVariable("pageNumber") Integer pageNumber, @RequestParam(defaultValue = "15") Integer pageSize) {
        Page<JobFeedback> jobPage = getPage(pageNumber, pageSize);
        return Rest.okData(iJobFeedbackService.selectByStatus(jobPage, status, memberId));
    }
}
